import QtQuick 2.1
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4

//定义RadioButtonStyle
RadioButton
{
    //定义单选框normal、hover状态下的颜色
    property color radiobuttonNormalColor: g_Colors.m_cRadioButtonBorderNormal
    property color radiobuttonHoveredColor: g_Colors.m_cRadioButtonBorderHover
    property color radiobuttonPressedColor:"white"
    property string m_fontfamily: ""
    //定义单选框内部填充颜色
    property color innerrColor: g_Colors.m_cRadioButtonInnerr
    //定义单选框外部部填充颜色
    property color outterNormalColor: g_Colors.m_cRadioButtonNormal
    property color outterPressedColor: g_Colors.m_cRadioButtonChecked
    //定义单选框文本normal和pressed状态下的颜色
    property color radiotextNormalColor: g_Colors.m_cRadioButtonTextNormal
    property color radiotextPressColor: g_Colors.m_cRadioButtonTextChecked
    //定义单选框的大小
    property int radioButtonWidth: 20
    property int radioButtonHeight : 20
    //定义内部填充的大小
    property int innerOffset : 10
    //定义单选框与文本之间的偏移量
    property real textSpacing: 3
    //文本字体的大小
    property int radiofontSize:20
    //字体是否加粗
    property bool fontBold: false
    //单选框弧度大小
    property int radioRadius: 0
    //单选框边框的大小
    property int radioBorderWidth:0
    //单选框默认显示的文本
    property string radioButtonText : ""

    property int fontsize : 12 //redioText.font.pixelSize
    property int textpixSise: 0

    signal radioButtonClick
    text:radioButtonText
    style:RadioButtonStyle
    {
        indicator: Rectangle
        {
            implicitWidth: radioButtonWidth%2?radioButtonWidth:radioButtonWidth - 1
            implicitHeight: radioButtonHeight%2?radioButtonHeight:radioButtonHeight - 1
            radius:radioRadius
            color: control.checked?outterPressedColor:outterNormalColor;
            border.color: control.hovered?radiobuttonHoveredColor:radiobuttonNormalColor
            border.width:radioBorderWidth
            Rectangle
            {
                id:inner
                width: innerOffset%2?innerOffset:innerOffset+1
                height: innerOffset%2?innerOffset:innerOffset+1
                anchors.centerIn: parent
                color: innerrColor
                visible: control.checked
                radius: radioRadius / 2
            }
        }
        label:LQBaseText{
            id : redioText
            color:control.checked?radiotextPressColor:radiotextNormalColor
            text:radioButtonText
//            font.pointSize: fontsize
            font.pixelSize: textpixSise;
//             font.family:m_fontfamily

        }
        spacing:textSpacing
    }
    onClicked: {
        radioButtonClick()
    }
}
